<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\service\kuaishou;

use app\enum\KsCodeEnum;
use app\enum\KuaiShouUrlEnum;
use app\service\BaseService;
use proxy\Client;
use think\Exception;

class AdvertiserService extends BaseService
{
    /**
     * 获取账户信息.
     * @param array $headers 头部
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getAccountInfo(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'advertiser_info');
            return $client->getJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 创建项目.
     * @param array $headers 头部
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function createProject(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'project_create');
            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 修改项目.
     * @param array $headers 头部
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function updateProject(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'project_update');
            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取智能托管.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getHostingProject(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'project_list');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取智能托管详情.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getHostingProjectDetail(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'project_detail');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取【应用中心】获取应用列表.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getAppList(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'app_list');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取定向模板
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getTargetTemplate(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'target_template_list');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取广告计划列表.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getCampaignList(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'campaign_list');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取行动号召按钮列表.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getActionList(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'action_list');

            $res = $client->getJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取创意分类标签白名单客户.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getCreativeCategoryLabelWhiteList(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'creative_category_label_white');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取创意分类查询接口.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getCreativeCategoryLabelList(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'creative_category_label');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取创意分类查询接口.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getCreativeTag(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'creative_tag');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取可选的动态词包.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getCreativeWord(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'creative_word');

            $res = $client->getJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取试玩列表.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getPlayable(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'playable_list');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取试玩按钮列表.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getPlayableButtons(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'playable_buttons');

            $res = $client->getJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取可选的深度优化目标.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getOcpxConversionDeepTypes(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'ocpx_conversion_deep_types');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取可选的浅度优化目标.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getOcpxConversionOcpxTypes(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'ocpx_conversion_ocpx_types');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取可选的浅度优化目标.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getAdvCard(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'adv_card');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取智能化创编广告组.
     *
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getUnitList(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'unit_list');

            $res = $client->getJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 更新智能化创编广告组.
     *
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function updateUnit(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'unit_update');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 创建广告计划.
     *
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function campaignCreate(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'campaign_create');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (! $res) {
                return self::setError('请求搭建失败');
            }
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError(json_encode($res, JSON_UNESCAPED_UNICODE));
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 修改广告计划状态.
     *
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function campaignStatus(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'campaign_status');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (! $res) {
                return self::setError('请求修改状态失败');
            }
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError(json_encode($res, JSON_UNESCAPED_UNICODE));
            }
            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 创建广告组.
     *
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function unitCreate(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'unit_create');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (! $res) {
                return self::setError('请求搭建失败');
            }
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError(json_encode($res, JSON_UNESCAPED_UNICODE));
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 创建自定义广告创意.
     *
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function creativeCreate(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'creative_create');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (! $res) {
                return self::setError('请求搭建失败');
            }
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError(json_encode($res, JSON_UNESCAPED_UNICODE));
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 创建程序化广告创意.
     *
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function programCreativeCreate(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'program_creative_create');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (! $res) {
                return self::setError('请求搭建失败');
            }
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError(json_encode($res, JSON_UNESCAPED_UNICODE));
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取快手广告主数据.
     *
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getAccountReport(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'account_report');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError(json_encode($res, JSON_UNESCAPED_UNICODE));
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取快手广告计划数据.
     *
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getCampaignReport(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'campaign_report');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError(json_encode($res, JSON_UNESCAPED_UNICODE));
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取快手账户组数据.
     *
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getUnitReport(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'unit_report');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError(json_encode($res, JSON_UNESCAPED_UNICODE));
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取新版分包发布列表【单元创编】.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getAppSubPackageList(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'app_subPackage');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取魔力建站落地页信息.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getLpPageList(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'lp_page');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取快手号授权列表.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getNativeAuthList(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'native_auth');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取原生视频列表接口.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getNativeVideoList(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'native_video');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }


    /**
     * 获取商品库列表.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getLibrary(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'library_list');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取商品列表.
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     */
    public static function getProduct(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'product_list');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            return self::setError($e->getMessage());
        }
    }

    /**
     * 获取智能化创编广告组.
     *
     * @param array $headers 头信息
     * @param array $params 参数
     * @return bool|mixed|string
     * @throws Exception
     */
    public static function getUnitTimeFrameList(array $headers = [], array $params = [])
    {
        $client = new Client();
        $serviceName = KuaiShouUrlEnum::getServiceName('advertiser');
        $serviceUrl = KuaiShouUrlEnum::getServiceUrl('advertiser', 'unit_list');

        $res = $client->getJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
        if (intval($res['code']) != KsCodeEnum::SUCCESS) {
            return self::setError($res['message']);
        }
        return $res;
    }
}
